<script setup>
import { onMounted, ref } from 'vue';

// 创建一个ref对象
const myInpRef = ref(null)
onMounted(() => {
  // myInpRef.value.focus()
})     

const btnRef = ref(null)
// console.log(btnRef.value)
onMounted(()=>{
  console.log(btnRef.value);
})

const clickMe = () => myInpRef.value.focus()
</script>

<template>
  <div>
    <input type="text" ref="myInpRef">
    <button ref="btnRef" @click="clickMe">点击</button>
  </div>
</template>

<style scoped></style>